package com.bckj.fastboot.paid.biz.infrastructure.sdk.wechatpay;

import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationParser;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class WechatPayNotificationParseManager {

    private static final Map<String, NotificationParser> PARSER_MAP = new ConcurrentHashMap<>();

    public static NotificationParser getParser(String outMerchantId) {
        return PARSER_MAP.computeIfAbsent(outMerchantId, key -> {
            Config config = WechatPayConfigProvider.getConfigByOutMerchantId(outMerchantId);
            return new NotificationParser((RSAAutoCertificateConfig) config);
        });
    }

}
